var http = createRequestObject();
var lastUrl = '';
var current_url = '';
var field = '';
var interval = '';


function createRequestObject() {
	var xmlhttp;
	try {xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}
	catch(e) {
    try {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	catch(f) {xmlhttp=null;}
  }
  if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
	xmlhttp=new XMLHttpRequest();
  }
	return  xmlhttp;
}

function do_search(mainURL) {
	kw = document.getElementById("keyword").value;
	if (!kw) alert('Bạn chưa nhập từ khóa');
	else {
		kw = encodeURIComponent(kw);
		last_url = '';
		window.location.href = '/index.php?go=search&keyword='+kw+'&type=song#ListSearch';
	}
	return false;
}
function do_templates() {
	temp_id = document.getElementById("template").value;
	window.location.href = mainURL+'index.php?template='+temp_id;
	return false;
}
// + ---------------------- +
// |        PLAYLIST        |
// + ---------------------- +

function reloadPlaylist(add_id,remove_id) {
	try{
		document.getElementById("playlist_field").innerHTML = loadingText;
		http.open('POST',  mainURL+'index.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = playlist_handleResponse;
		http.send('reloadPlaylist=1&add_id='+add_id+'&remove_id='+remove_id);
	}
	catch(e){}
	finally{}
}

function playlist_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			var response = http.responseText;
			document.getElementById("playlist_field").innerHTML = response;
		}
  	}
	catch(e){}
	finally{}
}
/**
 * @type=1: like music ==> media_id: song_id, type=2: like comment => media_id: comment_id
 * @param song_id
 * @author ThiepNN 
 */
function like(media_id, user_id, type) {

	if(typeof(user_id) == 'undefined') {
		alert('Bạn phải đăng nhập để sử dụng chức năng này !');
		return false;
	} else {
		$.ajax({
			url: url,
			data: 'actionLike=like&media_id=' + media_id + '&user_id=' + user_id + '&type=' + type,
			type: 'POST',
			dataType: 'json',
			success: function(data) {
				if(data.status == 'fail') {
					alert('Có lỗi xảy ra, vui lòng thử lại!');
					return false;
				} else {
                    $(".listLike").html(data.listLike);
					$("#buttonAction").html(data.button);
					$("#sumlike_"+media_id+'_1').html(data.sumLike);
					return false;	
				}
			}
		})
		return false;
	}

}

/**
 * @type=1: like music ==> media_id: song_id, type=2: like comment => media_id: comment_id
 * @param song_id
 * @author ThiepNN 
 */
function unlike(media_id, user_id, type) {

	if(typeof(user_id) == 'undefined') {
		alert('Bạn phải đăng nhập để sử dụng chức năng này !');
		return false;
	} else {
		
		$.ajax({
			url: url,
			data: 'actionLike=unlike&media_id=' + media_id + '&user_id=' + user_id + '&type=' + type,
			type: 'POST',
			dataType: 'json',
			success: function(data) {
				if(data.status == 'fail') {
					alert('Có lỗi trong quá trình like');
					return false;
				} else {
					$(".listLike").html(data.listLike);
					$("#buttonAction").html(data.button);
					$("#sumlike_"+media_id+'_1').html(data.sumLike);
					return false;
				}
			}
			
		})
		return false;
	}

}

function like_comment(media_id, user_id, type) {

	if(typeof(user_id) == 'undefined') {
		alert('Bạn phải đăng nhập để like');
		return false;
	} else {
		
		$.ajax({
			url: url,
			data: 'actionLike=like&media_id=' + media_id + '&user_id=' + user_id + '&type=' + type,
			type: 'POST',
			dataType: 'json',
			success: function(data) {
				if(data.status == 'fail') {
					alert('Có lỗi trong quá trình like');
					return false;
				} else {
					$("#like_comment_" + media_id).html(data.button);
					$("#sumlike_"+media_id+"_2").children("span").html(data.sumLike);
					return false;
					
				}
			}
			
		})
		return false;
	}

}

/**
 * @type=1: like music ==> media_id: song_id, type=2: like comment => media_id: comment_id
 * @param song_id
 * @author ThiepNN 
 */
function unlike_comment(media_id, user_id, type) {

	if(typeof(user_id) == 'undefined') {
		alert('Bạn phải đăng nhập để like');
		return false;
	} else {
		
		$.ajax({
			url: url,
			data: 'actionLike=unlike&media_id=' + media_id + '&user_id=' + user_id + '&type=' + type,
			type: 'POST',
			dataType: 'json',
			success: function(data) {
				if(data.status == 'fail') {
					alert('Có lỗi trong quá trình like');
					return false;
				} else {
					$("#like_comment_" + media_id).html(data.button);
					$("#sumlike_"+media_id+"_2").children("span").html(data.sumLike);
					return false;
				}
			}
		})
		return false;
	}

}
function addToPlaylist(song_id)
{
    playlist_id = $("select[name='list_playlist']").val();
    $("#error_pl").html('');
    if(playlist_id == '') {
        alert('Bạn cần phải chọn playlist trước !');
        return false;
    }
    $.ajax({
        url : url,
        data : 'actionPlaylist=addSong&song_id='+song_id+'&playlist_id='+playlist_id,
        type : 'POST',
        dataType : 'json',
        success : function(data) {
            if(data.status == 'fail') {
                $("#error_pl").html(data.msg);
            } else {
                playlist_change(playlist_id);
            }
        }
    });
}
function removeFromPlaylist(song_id)
{
    playlist_id = $("select[name='list_playlist']").val();
    $("#error_pl").html('');
    $.ajax({
        url : url,
        data : 'actionPlaylist=remove&song_id='+song_id+'&playlist_id='+playlist_id,
        type : 'POST',
        dataType : 'json',
        success : function(data) {
            if(data.status == 'fail') {
                $("#error_pl").html(data.msg);
            } else {
                playlist_change(playlist_id);
            }
        }
    });
}

/*------------------------------------------------------*/


function trim(a) {
	return a.replace(/^s*(S*(s+S+)*)s*$/, "$1");
}

// + ------------------- +
// |        LOGIN        |
// + ------------------- +
function login_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			document.getElementById("login_loading").style.display = "none";
			var response = http.responseText;
			if (response) {
				document.getElementById("login_loading").innerHTML = response;
				document.getElementById("login_loading").style.display = "block";
			}
			else 

			window.location.href = '?refresh=1';
		}
  	}
	catch(e){}
	finally{}
}

function login(form) {
name = encodeURIComponent(document.getElementById("name").value);
pwd = encodeURIComponent(document.getElementById("pwd").value);
	if(	trim(name) == "" ||	trim(pwd) == "")
		alert("Bạn chưa nhập đầy đủ thông tin");
	else {
		try{
			
			document.getElementById("login_loading").innerHTML = 'Đang tải dữ liệu ...';
			
			document.getElementById("login_loading").style.display = "block";
			
			http.open('POST',  mainURL+'index.php');
			
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = login_handleResponse;
			http.send('login=1&name='+name+'&pwd='+pwd);
			
			
		}
		catch(e){}
		finally{}
	}
	return false;
}

// + ---------------------- +
// |        REGISTER        |
// + ---------------------- +

function reg_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			document.getElementById("reg_loading").style.display = "none";
			var response = http.responseText;
			if (response) {
				document.getElementById("reg_loading").innerHTML = response;
				document.getElementById("reg_loading").style.display = "block";
			}
			else {
				alert("Bạn đã đăng kí thành công");
				window.location.href = mainURL+'index.php';
			}
		}
  	}
	catch(e){}
	finally{}
}

function reg_check_values() {
	ok = false;
	name = encodeURIComponent(document.getElementById("reg_name").value);
	pwd = encodeURIComponent(document.getElementById("reg_pwd").value);
	pwd2 = encodeURIComponent(document.getElementById("reg_pwd2").value);
	email = encodeURIComponent(document.getElementById("reg_email").value);
	agree = document.getElementById("agree").checked;
	
	s = document.getElementsByName("reg_sex");
	if (s[0].checked) sex = s[0].value;
	if (s[1].checked) sex = s[1].value;
	
	if(	trim(name) == "" ||	trim(pwd) == "" ||	trim(pwd2) == "" ||	trim(email) == "" )
		alert("Bạn chưa nhập đầy đủ thông tin");
	else
		if (pwd != pwd2) alert("Xác nhận mật khẩu không chính xác");
		else if (!agree) alert("Bạn chưa đồng ý với các quy định của trang Web");
		else {
			try{
				document.getElementById("reg_loading").innerHTML = loadingText;
				document.getElementById("reg_loading").style.display = "block";
				http.open('POST',  mainURL+'index.php');
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = reg_handleResponse;
				http.send('reg=1&name='+name+'&pwd='+pwd+'&email='+email+'&sex='+sex);
				
			}
			catch(e){}
			finally{}
		}
	return ok;
}


// + ----------------------------- +
// |        FORGOT PASSWORD        |
// + ----------------------------- +

function forgot_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			document.getElementById("forgot_loading").style.display = "none";
			var response = http.responseText;
			if (response) {
				document.getElementById("forgot_loading").innerHTML = response;
				document.getElementById("forgot_loading").style.display = "block";
			}
		}
  	}
	catch(e){}
	finally{}
}

function forgot() {
	email = encodeURIComponent(document.getElementById("u_email").value);
	if(	trim(email) == "" )	alert("Bạn chưa nhập email");
	else {
		try{
			document.getElementById("forgot_loading").innerHTML = loadingText;
			document.getElementById("forgot_loading").style.display = "block";
			http.open('POST',  mainURL+'index.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = forgot_handleResponse;
			http.send('forgot=1&email='+email);
		}
		catch(e){}
		finally{}
	}
	return false;
}



// BEGIN RATING
function Rating(media_id,star) {
	try {
		hide_rating_process();
		http.open('POST',  mainURL + 'rating.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = function() {
			if((http.readyState == 4)&&(http.status == 200)){
				document.getElementById("rating_field").innerHTML = http.responseText;
			}
		}
		http.send('rating=1&media_id='+media_id+'&star='+star);
	}
	catch(e){}
	finally{}
	return false;
}


	// pre-fetch image
	(new Image()).src = RATE_OBJECT_IMG;
	(new Image()).src = RATE_OBJECT_IMG_HALF;
	(new Image()).src = RATE_OBJECT_IMG_BG;

	function show_star(starNum) {
		remove_star();
		full_star(starNum);
	}
	
	function full_star(starNum) {
		for (var i=0; i < starNum; i++)
			document.getElementById('star'+ (i+1)).src = RATE_OBJECT_IMG;
	}
	function remove_star() {
		for (var i=0; i < 5; i++)
			document.getElementById('star' + (i+1)).src = RATE_OBJECT_IMG_BG; // RATE_OBJECT_IMG_REMOVED;
	}
	function show_rating_process() {
		document.getElementById("rating_process").style.display = "block";
		document.getElementById("rate_s").style.display = "none";
	}
	function hide_rating_process() {
		document.getElementById("rating_process").style.display = "none";
		document.getElementById("rate_s").style.display = "block";
	}

// END RATING

function Display_Load()
{
    $("#loading1").fadeIn(900,0);
    $("#loading1").html("<img src='<?=$mainURL;?>/loading.gif' />");
}
//Hide Loading Image
function Hide_Load()
{
    $("#loading1").fadeOut('slow');
}

function showComment() {
    var startValue = $("#cntComment").val();        
    console.log(startValue);
    var tmp = $("#cntComment").attr('name');
    var mediaId = tmp.replace('cntComment_','');
    if (startValue == '') {
        startValue = 1;
    } else {
        startValue = eval(startValue);
    }
    
    Display_Load();
    $.ajax({
        url : url + "/comment.php",
        data : 'showcomment=1&media_id='+mediaId+'&pg='+startValue,
        type : "GET",
        dataType : "json",
        success : function(data) {
            Hide_Load();
            if ($("#note-text").find("li:not(#emptyComment)").length == 0) {
                $("#note-text").html(data.comment);
            } else {
                $("#note-text").children("li").last().after(data.comment);
            }
            
            if(data.sumComment == $("#note-text li").length)
                $("#nextComment").hide();
            
            if($("#note-text #emptyComment").length != 0)
                $("#nextComment").hide();
            
            startValue++;
            $("#cntComment").val(startValue);
        }
    });
}


function comment_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			var response = http.responseText;
			if (response == 'OK') {
				media_id = encodeURIComponent(document.getElementById("media_id").value);
				showComment(media_id);
			}
			else document.getElementById("comment_loading").innerHTML = response;

		}
  	}
	catch(e){}
	finally{}
}

function comment_check_values() {
	media_id = encodeURIComponent(document.getElementById("media_id").value);
	comment_content = encodeURIComponent(document.getElementById("comment_content").value);
    $(".comment_error").html("");
	if(trim(comment_content) == "")
		$(".comment_error").html("Bạn chưa nhập bình luận !");
	else if (comment_content.length > 255)
		$(".comment_error").html("Nội dung bình luận quá 255 ký tự.");
	else {
        $("#loading1").fadeIn();
        $(".commentClick").hide();
        $("#comment_content").attr("disabled","disabled");
        $.ajax({
            url : url + '/comment.php',
            data : 'comment=1&media_id='+media_id+'&comment_content='+comment_content,
            type : "POST",
            dataType : 'json',
            success : function(data) {
                $("#loading1").fadeOut();
                if(data.status == 'fail') {
                    $(".comment_error").html(data.msg);
                } else if(data.status == 'success') {
                    $("#comment_content").val('');
                    $("#comment_content").removeAttr("disabled");
                    $(".commentClick").show();
                    $("#note-text").find("#emptyComment").remove();
                    if($("#note-text").find("li").length != 0) {
                        $("#note-text").find("li").first().before(data.msg);
                    } else {
                        $("#note-text").append(data.msg);
                    }
                }
            }
        });
	}
	return false;
}

function comment_delete(media_id,comment_id) {
    $(".comment_error").html("");
    $("#loading1").fadeIn();
    $.ajax({
        url : url + '/comment.php',
        data : 'delete=1&media_id='+media_id+'&comment_id='+comment_id,
        type : "POST",
        dataType : 'json',
        success : function(data) {
            $("#loading1").fadeOut();
            if(data.status == 'fail') {
                $(".comment_error").html(data.msg);
            } else if(data.status == 'success') {
                $("#note-text").find("li#comment_"+comment_id).fadeOut().remove();
                if($("#note-text").find("li").length == 0) {
                    showComment();
                }
            }
        }
    });
	return false;
}

if(window.location.host.search('www') == 0)window.location.replace(window.location.href.replace('http://www.','http://'));

/**
* Function add playlist for user
* @user_id : ID of user
*/
function playlist_add(user_id) {
    name_pl = prompt('Xin mời đặt tên cho playlist !');
    if(name_pl != '') {
        $.ajax({
            url : url,
            data : 'actionPlaylist=add&name_pl='+name_pl+"&user_id="+user_id,
            type : 'POST',
            dataType : 'json',
            success : function(data) {
                if(data.status == 'success') {btn = '<option value='+data.playlist_id+'>'+data.name_pl+'</option>';
                    $("select[name='list_playlist']").children().removeAttr('selected');
                    $("select[name='list_playlist']").children().last().after(btn);
                    $("select[name='list_playlist']").find("option[value='"+data.playlist_id+"']").attr('selected','selected');
                    $("#playlist_field").children().remove();
                    $("#playlist_field").append("<li><p class='title'>Playlist chưa có bài hát</a></p></li>");
                } else {
                    $("#error_pl").html('Có lỗi xảy ra, xin vui lòng thử lại !');
                }
            }
        });
    } else {
        alert('Bạn không được để trống tên playlist !');
        return false;
    }
}

/**
* Function to change value of select playlist
* @playlist_id : Id of playlist choosed
*/
function playlist_change(playlist_id) {
        $("#playlist_field").children().remove();
        $.ajax({
            url : url,
            data : 'actionPlaylist=change&playlist_id='+playlist_id,
            type : 'POST',
            dataType : 'json',
            success : function(data) {
                $("#playAllPlaylist").remove();
                $("#playlist_field").html(data.html).after(data.playAll);
            }
        });
}

/**
* Function to remove playlist
* @playlist_id : Id of playlist want to delete
*/
function playlist_remove(playlist_id) {
    if($("select[name='list_playlist']").val() == '') return false;
    $.ajax({
        url : url,
        data : 'actionPlaylist=removePlaylist&playlist_id='+playlist_id,
        type : 'POST',
        dataType : 'json',
        success : function(data) {
            if(data.status == 'fail') {
                $("#error_pl").html(data.msg);
            } else {
                $("#playlist_field").html('');
                $("#playlist_field").append("<li><p class='title'>Bạn cần chọn 1 playlist</a></p></li>");
                $("#playAllPlaylist").remove();
                $("select[name='list_playlist']").find("option[value='"+playlist_id+"']").remove();
                $("select[name='list_playlist']").children().first().attr('selected','selected');
            }
        }
    });
}


/**
 * Function to request add friend
 * @user_id : Id of user want request add friend
 */
function addFriend(userId) {
    $(".widget .title").find('.error').remove();
    $.ajax({
        url : url,
        data : "actionFriend=add&user_id="+userId,
        type : "POST",
        dataType : "json",
        success : function(data) {
            if(data.status == 'success') {
                $(".widget .title").find(".addFriend").remove();
                $(".widget").first().find(".title").append('<p id="Friend_'+userId+'" class="addFriend isFriend requestFriend">Đang chờ phản hồi</p>');
            } else {
                $(".widget .title").after('<p class="error"></p>');
                $(".widget .title .error").html(data.msg);
            }
        }
    });
}



/**
 * Function use to auto request notification
 * 
 */
function autoRequest() {
    $.ajax({
        url : url,
        data : "actionAuto=request",
        type : "POST",
        dataType : 'json',
        success : function(data) {
            if(data.totalFriend != 0) {
                $("#cntFriend").fadeIn().html(data.totalFriend);
            }
            if(data.totalNoti != 0) {
                $("#cntPush").fadeIn().html(data.totalNoti);
            }
        }
    });
    
    timeOut = setTimeout("autoRequest()", timeAutoRequest);
}


/**
 * Function to load all user request add friend
 * 
 */
function loadRequestFriend() {
    $("#cntFriend").hide();
    $("#notiFriend .ntlist").html('').append("<center><img src='"+url+"/ajax-loader.gif' alt='Ajax Loader'/></center>");
    $.ajax({
        url : url,
        data : "actionAuto=showFriendRequest",
        type : "POST",
        dataType : 'json',
        success : function(data) {
            $("#notiFriend .ntlist").find("center").remove();
            $("#notiFriend .ntlist").html(data.msg);
        }
    });
}

/**
 * Function to load all notification for user
 */
function loadRequestNoti() {
    $("#cntPush").hide();
    $("#notiPush .ntlist").html('').append("<center><img src='"+url+"/ajax-loader.gif' alt='Ajax Loader'/></center>");
    $.ajax({
        url : url,
        data : "actionAuto=showNotification",
        type : "POST",
        dataType : 'json',
        success : function(data) {
            $("#notiPush .ntlist").find("center").remove();
            $("#notiPush .ntlist").html(data.msg);
        }
    });
}

/**
 * Function to accept request add friend
 * 
 */
function actionRequestAddFriend(requestID, action) {
    var ajaxLoader = "<img src='"+url+"/ajax-loaderRequest.gif' alt='Ajax Loader' id='ajaxLoaderRequest' style='padding-left:2px'/>";
    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find('.acceptRequest').hide();
    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find(".declineRequest").hide();
    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find(".declineRequest").after(ajaxLoader);
    if(action == 'accept') {
        $.ajax({
            url : url,
            data : "actionAuto=accept&requestID="+requestID,
            type : "POST",
            dataType : 'json',
            success : function(data) {
                if(data.status == 'success') {
                    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).fadeOut().remove();
                } else {
                    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find('.acceptRequest').show();
                    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find(".declineRequest").show();
                    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find("#ajaxLoaderRequest").remove();
                }
            }
        });
    } else if (action='decline') {
        $.ajax({
            url : url,
            data : "actionAuto=decline&requestID="+requestID,
            type :"POST",
            dataType : 'json',
            success : function(data) {
                if(data.status == 'success') {
                    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).fadeOut().remove();
                    if($("#notiFriend .ntlist").find(".friendRequest").length == 0) {
                        $("#notiFriend .ntlist").html("Không có yêu cầu mới");
                    }
                } else {
                    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find('.acceptRequest').show();
                    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find(".declineRequest").show();
                    $("#notiFriend .ntlist").find("#friendRequest_"+requestID).find("#ajaxLoaderRequest").remove();
                }
            }
        });
    }
}



/************************Module Push, Comment, Notification, Add Friend**************************/
/**
 * @author Anh Nguyen <duyanhnguyen@vccorp.vn>
 * @copyright 2012
 */

$(document).ready(function() {
    $(".ntbtn").click(function() {
        var idBtn = $(this).attr('id');
        var idCnt = 'cnt' + idBtn.replace('btn', '');
        var idPop = 'noti' + idBtn.replace('btn', '');
        if($("#" + idPop).css('display') == 'none') {
            $("body").find("#popupBg").remove();
            $(".notify").fadeOut();
            $("#" + idPop).fadeIn();
            if(idBtn == 'btnPush') {
                $(this).css('background-position','-23px -5px');
            } else {
                $(this).css('background-position','-70px -41px');
            }
            var popupBg = "<div id='popupBg'></div>";
            $("body").append(popupBg);
            clearTimeout(timeOut);
        } else {
            $("#popupBg").remove();
            $("#" + idPop).fadeOut();
            if(idBtn == 'btnPush') {
                $(this).css('background-position','-50px -74px');
            } else {
                $(this).css('background-position','-22px -74px');
            }
            autoRequest();
        }
    });
    
    $("#btnFriend").click(function() {
        loadRequestFriend();
    });
    
    $("#btnPush").click(function() {
        loadRequestNoti();
    });
    
    $("#popupBg").live('click', function() {
        $("#popupBg").remove();
        $(".notify").fadeOut();
        $("#btnPush").css('background-position','-50px -74px');
        $("#btnFriend").css('background-position','-22px -74px');
        autoRequest();
    });
    
    $("a.addFriend:not(.commentClick)").live('click', function() {
        var userID = eval($(this).attr('id').replace('addFriend_',''));
//        console.log(userID);
        addFriend(userID);
        return false;
    });
    
    $(".acceptRequest").live('click', function() {
        requestID = $(this).attr('id').replace('accept_','');
        actionRequestAddFriend(requestID, 'accept');
        return false;
    });
    
    $(".declineRequest").live('click', function() {
        requestID = $(this).attr('id').replace('decline_','');
        actionRequestAddFriend(requestID, 'decline');
        return false;
    });
    
    $(".sumlike").live('click', function() {
        var id = $(this).attr('id');
        id = id.replace('sumlike_', '');
        var idArray = id.split('_');
        var idLike = idArray[0];
        var typeLike = idArray[1];
        $.ajax({
            url : url,
            data : "actionLike=showUserLike&idLike="+idLike+"&typeLike="+typeLike,
            type : "POST",
            dataType : 'json',
            success : function(data) {
                if(data.status == 'success') {
                    $.modal(data.html, {
                        'overlayClose' : true,
                        'focus' : false,
                        'autoResize' : true 
                    });
                    $("#listUserLike ul").tinyscrollbar();
                } else {
                    alert("Có lỗi xảy ra, vui lòng thử lại !");
                }
            }
        });
        return false;
    });
});

